﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int firstNumber = int.Parse(textBox1.Text);
            int secondNumber = int.Parse(textBox2.Text);
            bool flag;
            for (int i = firstNumber; i <= secondNumber; i++)
            {
                flag = true;
                for (int j = 2; j < i; j++)
                {
                    if (i % j == 0)
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    textBox3.Text = textBox3.Text + " "+i;
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string str = textBox8.Text;
            string[] result = str.Split(' ');
            int[] myArray = new int[result.Length];
            for (int m = 0; m < result.Length; m++)
            {
                myArray[m] = int.Parse(result[m]);
            }

            textBox4.Text = ""+myArray.Max();
            textBox5.Text = "" + myArray.Min();
            textBox6.Text = "" + myArray.Average();
            textBox7.Text = "" + myArray.Sum();
        }
    }
}
